package experiment.e05.code;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/10/13 15:35
 * @package experiment.e05.code
 * @description
 * 设计一个类Student类，该类从Personal派生，
 * 该类有学生学号studentID、所在的系部department、年级grade。
 * 新的Student类中有相应的构造函数、查询及输出学生个人信息的getInfo()与print()方法。
 * 再设计一个测试类TestStudent,测试该类。
 */

public class Ch02 {
}

/**
 * 测试类
 */
class TestStudent {
    public static void main(String[] args) {
        // 学生类对象
        Student student = new Student
                (21, "刘宋", 21, '男', 43, "计算机科学", "大四");
        // 测试getInfo方法
        System.out.println(student.getInfo());
        // 测试print方法
        student.print();
    }
}

/**
 * 学生类
 */
class Student extends Personal {
    // 实例变量
    private int studentID;
    private String department;
    private String grade;

    // 构造方法
    public Student() {
    }

    public Student(int studentID, String department, String grade) {
        this.studentID = studentID;
        this.department = department;
        this.grade = grade;
    }

    public Student(int id, String name, int age, char sex, int studentID, String department, String grade) {
        super(id, name, age, sex);
        this.studentID = studentID;
        this.department = department;
        this.grade = grade;
    }

    /**
     * 查询学生的个人信息
     *
     * @return
     */
    public String getInfo() {
        return "getInfo:Student{" +
                "studentID=" + studentID +
                ", department='" + department + '\'' +
                ", grade='" + grade + '\'' +
                "} ";
    }

    /**
     * 打印学生信息
     *
     * @return
     */
    public void print() {
        System.out.println("print:Student{" +
                "id=" + super.getId() +
                ", name='" + super.getName() + '\'' +
                ", age=" + super.getAge() +
                ", sex=" + super.getSex() +
                ", studentID=" + studentID +
                ", department='" + department + '\'' +
                ", grade='" + grade + '\'' +
                "}");
    }
}
